package com.autumn.sms.service.services.dto.input;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import io.swagger.annotations.ApiModelProperty;

/**
 *应用-模板输入
 * @author JuWa ▪ Zhang
 * @date 2018年1月13日
 * @since jdk 1.8
 */
public class SmsAppTemplateInput {
	@ApiModelProperty(value = "排序ID")
	private Integer sortId;
	@ApiModelProperty(value = "应用ID", required = true)
	@NotNull(message = "应用ID不能为空")
	private Long appId;
	@ApiModelProperty(value = "标准模板ID", required = true)
	@NotNull(message = "标准模板ID不能为空")
	private Long templateId;
	@ApiModelProperty(value = "备注")
	private String remark;
	@Valid
	private List<SmsAppTemplatePlatformInput> appTemplatePlatforms;
	public Integer getSortId() {
		return sortId;
	}
	public void setSortId(Integer sortId) {
		this.sortId = sortId;
	}
	public Long getAppId() {
		return appId;
	}
	public void setAppId(Long appId) {
		this.appId = appId;
	}
	public Long getTemplateId() {
		return templateId;
	}
	public void setTemplateId(Long templateId) {
		this.templateId = templateId;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public List<SmsAppTemplatePlatformInput> getAppTemplatePlatforms() {
		if (appTemplatePlatforms == null) {
			appTemplatePlatforms = new ArrayList<>();
		} else {
			Set<Long> nameSet = new HashSet<>();
			Iterator<SmsAppTemplatePlatformInput> iterator = appTemplatePlatforms.iterator();
			while (iterator.hasNext()) {
				SmsAppTemplatePlatformInput item = iterator.next();
				if (! nameSet.add(item.getPlatformTemplateId())) {
					iterator.remove();
				}
			}
		}
		return appTemplatePlatforms;
	}
	public void setAppTemplatePlatforms(List<SmsAppTemplatePlatformInput> appTemplatePlatforms) {
		this.appTemplatePlatforms = appTemplatePlatforms;
	}
}
